import { MidwayConfig } from '@midwayjs/core';
// import path = require('path');

export default {
  // use for cookie sign key, should change to your own and keep security
  keys: '1698198316534_436',
  app: {
    security: {
      prefix: '/api',
      ignore: ['/api/login'],
    },
  },
  koa: {
    port: 7001,
  },
  bodyParser: {
    enableTypes: ['json', 'form', 'text', 'xml'],
    formLimit: '1mb',
    jsonLimit: '1mb',
    textLimit: '1mb',
    xmlLimit: '1mb',
  },
  typeorm: {
    dataSource: {
      default: {
        /**
         * 单数据库实例
         */
        type: 'mysql',
        host: process.env.MYSQL_HOST,
        port: Number(process.env.MYSQL_PORT),
        username: process.env.MYSQL_USERNAME,
        password: process.env.MYSQL_PASSWORD,
        database: 'tqlmidway',
        synchronize: true, // 如果第一次使用，不存在表，有同步的需求可以写 true，注意会丢数据
        logging: false,

        // 配置实体模型
        // entities: [Photo],

        // 或者扫描形式
        entities: ['**/entities/*.entity{.ts,.js}'],
      },
    },
  },
  jwt: {
    secret: 'setscrew',
    expiresIn: 60 * 60 * 24,
  },
  redis: {
    client: {
      host: process.env.REDIS_HOST,
      port: process.env.REDIS_PORT,
      password: process.env.REDIS_PASSWORD,
      db: 0,
    },
  },
  swagger: {
    title: 'tqlmidway',
    description: 'Midway脚手架',
    auth: {
      authType: 'bearer',
    },
  },
  staticFile: {
    dirs: {
      default: {
        prefix: '/static/',
        dir: 'public',
      },
      // another: {
      //   prefix: '/public',
      //   dir: path.join(__dirname, 'public'),
      // },
    },
  },
} as MidwayConfig;
